	#include<iostream>
	#include<queue>
	#include<algorithm>
	using namespace std;
	typedef pair<int, int> PII;
	#define x first
	#define y second
	const int N = 210;
	int arr[N * N];
	char g[N][N];
	bool st[N][N];
	int dx[4] = { -1,0,1,0 };
	int dy[4] = { 0,1,0,-1 };
	int n, m;
	int bfs(int x, int y)
	{
		queue<PII> q;
		q.push({ x,y });
		int ans = 0;
		st[x][y] = 1;
		while (q.size()) {
			PII t = q.front();
			q.pop();
			ans++;
			for (int i = 0; i < 4; i++) {
				int a = dx[i] + t.x;
				int b = dy[i] + t.y;
				if (g[a][b] == '#' || st[a][b] == 1) {
					continue;
				}
				if (a < 0 || a >= n || b < 0 || b >= m) {
					continue;
				}
				st[a][b] = 1;
				q.push({ a,b });
			}
		}
		return ans;
	}
	int main()
	{
		cin >> n >> m;
		for (int i = 0; i < n; i++) {
			cin >> g[i];
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (g[i][j] == '.' && !st[i][j]) {
					arr[ans++] = bfs(i, j);
				}
			}
		}
		cout << ans << endl;	
		sort(arr, arr + ans);
		for (int i = 0; i < ans; i++) {
			cout << arr[i] << " ";
		}
		return 0;
	}